#!/usr/bin/env node

// 创建 timer1 定时器
const timer1 = setTimeout(() => {
    console.log('Timer 1 ended, starting Timer 2.');
    
    // 清除 timer1 定时器
    clearTimeout(timer1);
    
    // 创建 timer2 定时器
    let count = 0;
    const timer2 = setInterval(() => {
      console.log('Timer 2 tick');
      count++;
      if (count === 5) {
        console.log('Timer 2 has executed 5 times, exiting.');
        clearInterval(timer2);
      }
    }, 500);
  }, 5000);
  
  // 立即启动 timer1 定时任务，每 500 ms 执行一次
  const interval1 = setInterval(() => {
    console.log('Timer 1 tick');
  }, 500);
  
  // 倒计时 5 秒后结束 interval1 并启动 timer1
  setTimeout(() => {
    console.log('Stopping Timer 1 after 5 seconds.');
    clearInterval(interval1);
    clearTimeout(timer1);
  }, 5000);

